﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Threading;
using Urb.Weather.Core.UI;

namespace Urb.Weather.Ticker.UI
{
    internal class Dispatcher : IDispatcher
    {
        private DispatcherObject dispatcherObject;

        public Dispatcher(DispatcherObject dispatcherObject)
        {
            this.dispatcherObject = dispatcherObject;
        }

        public void Dispatch(Action action)
        {
            if (!dispatcherObject.Dispatcher.CheckAccess())
            {
                dispatcherObject.Dispatcher.BeginInvoke(action);
            }
            else
            {
                action();
            }
        }
    }
}
